<!---- Creator: Eoly -->
<!---- On 2017/1/10 -->
<!---- Call http://palerock.cn -->

<!--
    注册API：
    method:POST
    url:'http://palerock.cn/h5_back/register'
    data:
    {                           // 发送json参数
        'userPhoneNumber':''    // 用户电话号码
        'userLoginPsw':''       // 用户登录密码
    }
    返回：
    {
        error:      // '0'则为操作成功
        id:         // 操作成功返回注册后的id
        mes:        // 操作后返回的信息
    }
-->

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no">
    <title>AngularTest</title>
    <style>
        * {
            padding: 0;
            margin: 0;
            /*border: 0;*/
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }
    </style>
    <script src="../angular.js"></script>
    <script>
        var net = "http://palerock.cn/h5_back";
//        var net = "http://localhost:8080";

        var app = angular.module('app', []);
        app.controller('register', function ($scope, $http) {
            //用户电话号码
            $scope.userPhoneNumber = '';
            //用户登录密码
            $scope.userLoginPsw = '';
            $scope.registering = function(){
                var registorInfo = {'userPhoneNumber':$scope.userPhoneNumber,'userLoginPsw':$scope.userLoginPsw};
                $http.post(net+'/register',registorInfo).then(function(res){
                    console.log(res);
                    if(!res.data.error){
                        alert('注册成功，你的id是：'+res.data.id)
                    }else{
                        alert("错误代码:"+res.data.error+","+res.data.mes)
                    }
                },function(){
                    alert('注册失败');
                })
            }
        });
    </script>
</head>
<body ng-app="app">
<div ng-controller="register">
    <input type="text" ng-model="userPhoneNumber" placeholder="输入手机号">
    <input type="password" ng-model="userLoginPsw" placeholder="输入密码">
    <button ng-click="registering()">注册</button>
	<a href="登陆简单演示.html">登录页面</a>
    <a href="所有团信息获取.html">所有团页面（不需登录）</a>
</div>

</body>
</html>